package com.meixiang.activity.account.managers.myPurse;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.meixiang.R;
import com.meixiang.activity.homes.service.OrderSubmissionSuccessfulActivity;
import com.meixiang.activity.homes.shopping.CashierDeskActivity;
import com.meixiang.entity.OrderResult;
import com.meixiang.main.BaseActivity;
import com.meixiang.tool.Tool;
import com.meixiang.view.TitleView;

import java.util.HashMap;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 我的钱包   申请充值成功
 *
 * @author zys
 */
public class RechargeSucceedActivity extends BaseActivity {

    @Bind(R.id.title)
    TitleView title;
    @Bind(R.id.repay_success)
    ImageView repaySuccess;
    @Bind(R.id.tv_recharge_entry_money)
    TextView tvRechargeEntryMoney;
    @Bind(R.id.tv_recharge_details_type)
    TextView tvRechargeDetailsType;
    @Bind(R.id.tv_recharge_time)
    TextView tvRechargeTime;
    @Bind(R.id.tv_recharge_transaction_number)
    TextView tvRechargeTransactionNumber;
    @Bind(R.id.tv_recharge_account_balance)
    TextView tvRechargeAccountBalance;

    private OrderResult mOrderResult;
    private HashMap<String, Class> gotoActivityMap;

    @SuppressWarnings("unchecked")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_recharge_succeed);
        ButterKnife.bind(this);
        Intent intent = getIntent();
        if (intent != null) {
            mOrderResult = intent.getParcelableExtra(CashierDeskActivity.ORDER_RESULT);
            gotoActivityMap = (HashMap<String, Class>) intent.getSerializableExtra(CashierDeskActivity.GOTO_ACTIVITY);
        }
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initTitle() {
        title.setTitle("余额充值");
        title.setLeftImageButton(R.mipmap.back);
        title.showLeftButton(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        title.setRightTextButton("完成");
        title.showRightButton(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Tool.isFastDoubleClick()) return;
                if (gotoActivityMap == null || gotoActivityMap.get(CashierDeskActivity.GOTO_ACTIVITY) == null)
                    return;
                Intent intent = new Intent(RechargeSucceedActivity.this, gotoActivityMap.get(CashierDeskActivity.GOTO_ACTIVITY));
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void initView() {
        if (mOrderResult == null) return;
        tvRechargeEntryMoney.setText("+" + mOrderResult.getOrderAmount());
    }

    @Override
    protected void setData() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

    @Override
    public void onClick(View v) {

    }
}
